﻿using System;
using System.Collections.Generic;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTLocalVarDecltor : ASTNode
    {
        public string ident { get; set; }
    }

    public class ASTLocalVarDecltors : List<ASTLocalVarDecltor>
    {
        public override string ToString()
        {
            return Strings.joinobjs(", ", this);
        }
    }

    public class ASTLocalVarDecltorNormal : ASTLocalVarDecltor
    {
        public ASTVariableInitializer varInitializer { get; set; }

        public override string ToString ()
        {
            if (varInitializer == null)
                return ident;
            else
                return ident + " = " + varInitializer.ToString(); 
        }
    }

    public class ASTLocalVarDecltorStackalloc : ASTLocalVarDecltor
    {
        public ASTType          type        { get; set; }
        public ASTExpr    expression  { get; set; }

        public override string ToString()
        {
            return ident + " = stackalloc " + type.ToString() + "[" + expression.ToString() + "]";  
        }
    }
}
